# src/api/reports.py
from fastapi import APIRouter, HTTPException, Query
from typing import List, Optional
from .. import crud
router = APIRouter(tags=["reports"])


@router.get("/appointments/details")
def appointments_details(limit: int = Query(100, ge=1, le=1000)):
    return crud.appointments_with_details(limit=limit)


@router.get("/revenue/department")
def revenue_per_department():
    return crud.revenue_per_department()


@router.get("/doctors/busy")
def doctors_busy(month: int = Query(..., ge=1, le=12), year: int = Query(..., ge=2000), threshold: int = Query(10, ge=1)):
    return crud.doctors_with_more_than_x_appointments(month=month, year=year, threshold=threshold)


@router.get("/patients/outstanding")
def patients_outstanding():
    return crud.patients_with_outstanding_invoices()


@router.get("/appointments/available")
def available_appointments(date: str = Query(..., description="Target date YYYY-MM-DD")):
    # returns staff with no appointments that day
    return crud.available_appointments_by_date(date)
